<?php
load_ctl("Common");
class WritemoodController extends CommonController
{ 
	function init(){
		parent::init();
		load_model('WriteMood');
		$this->wd = new WriteMood();
    }
	public function indexAction(){
		if(!isset($_GET["tk"]) || trim($_GET['tk']) != md5('phblog') || time()-$_GET['t'] > 60){
			$this->_redirect('/');
		}	
		echo $this->view->render('addmood.phtml');        
	}
	
	public function addmoodAction(){
		if($this->_request->isPost()){
			$filter = new Zend_Filter_StripTags();
			$mood_content = $filter->filter($this->_request->getPost('mood_content'));
			$data = array(
				'mood_content'=>$mood_content,
				'mood_date'=>time()
			);
			$this->wd->add_wm($data);
			php_alert("发表成功","/");
		}else{
			$this->_redirect('/');
		}
	}
	
	public function noRouteAction(){
		$this->_redirect('/');
	}
}
?>